TAncetmean <- function(category, id = 10:20) {
  fileslist <- c()
  directory<-"C:\\Users\\E807578\\Downloads\\Tsunami\\csv\\"
  
  for(i in id){
    filename <- paste(i, ".csv", sep="")
    fileslist <- c(fileslist, filename)
    
  }
  
  FList<-list.files(directory,pattern=".csv",full.names=TRUE)
  print(FList[id])
  
  data <- do.call(rbind, lapply(FList[id],read.csv))
  
  
  
  mm <- mean(data[[category]], na.rm=TRUE)
  print(mm)
  
  
  #View(sort(data[[category]], decreasing=TRUE))
  #View(data[ order(-data[["mba"]]), ])
  #View(data[ order(-data[["me"]]), ])
  #View(data[ order(-data[["mca"]]), ])
  #write.table(data[ order(-data[[category]]), ], quote = FALSE, sep = ",")
  # Write CSV in R
 # write.csv(data[ order(-data[[category]]), ], file = "MyData.csv",row.names=FALSE, na="")
  # plot(data[ order(-data[[category]]), ])
  
  library(data.table)
  DT <- as.data.table(data)
  #View(DT[,yrrank:=rank(-data[[category]],ties.method="first"),])
# write.csv(DT[,yrrank:=rank(-data[[category]],ties.method="first"),], file = "ME.csv",row.names=FALSE, na="")
 
 medata <-DT[,MERank:=rank(-data[["me"]],ties.method="first"),]
 mbadata <-medata[,MbaRank:=rank(-data[["mba"]],ties.method="first"),]
 mcadata <-mbadata[,MCARank:=rank(-data[["mca"]],ties.method="first"),] 
 write.csv(mcadata, file = "all.csv",row.names=FALSE, na="")
}
